package com.supermap.dataservice.meto.life;

import com.supermap.dubbo.api.cloud.warnInfo.WarnInfo;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @author aqua
 * @description
 * @date 2020年04月20 15:24
 * @email 1301584033@qq.com
 */
@Mapper
public interface LifeMapper {
    /**
     *多条入库
     * */
    @InsertProvider(type = LifeMapperSQL.class,method = "insertLifeSQL")
    int insertLifeSQL(@Param("lifeModes") List<LifeMode> lifeModes );

    class LifeMapperSQL{


        /**
         *多条入库
         * */
        public String insertLifeSQL(Map<String,Object> map){
            List<LifeMode> lifeModes=(List<LifeMode>)map.get("lifeModes");
            StringBuilder stringBuilder=new StringBuilder();
            stringBuilder.append(" insert  IGNORE  into t_life_index(cityCode,forecastTime,weatherDescription,dryingIndeX,cityFireIndeX,wishingCarIndeX,warehouseFireIndeX,drinkIndex,dressIndex,feverIndex,tourIndex,morningExecIndex,cozyIndex,humidityIndex,driveIndex,beerIndex,makeupIndex,lookIndex) ");
            stringBuilder.append(" values ");
            if(lifeModes!=null&&lifeModes.size()>0){
                for (LifeMode lifeMode:lifeModes){
                    stringBuilder.append("(");
                    stringBuilder.append("'"+lifeMode.getCityCode()+"',");
                    stringBuilder.append("'"+lifeMode.getForecastTime()+"',");
                    stringBuilder.append("'"+lifeMode.getWeatherDescription()+"',");
                    stringBuilder.append("'"+lifeMode.getDryingIndeX()+"',");
                    stringBuilder.append("'"+lifeMode.getCityFireIndeX()+"',");
                    stringBuilder.append("'"+lifeMode.getWishingCarIndeX()+"',");
                    stringBuilder.append("'"+lifeMode.getWarehouseFireIndeX()+"',");
                    stringBuilder.append("'"+lifeMode.getDrinkIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getDressIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getFeverIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getTourIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getMorningExecIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getCozyIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getHumidityIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getDriveIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getBeerIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getMakeupIndex()+"',");
                    stringBuilder.append("'"+lifeMode.getLookIndex()+"'");
                    stringBuilder.append("),");
                }
            }
            return stringBuilder.substring(0,stringBuilder.lastIndexOf(","));

        }
    }
}
